home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / cmds / dviselect / io.h < prev    next >
Encoding:
C/C++ Source or Header  |  1989-06-16  |  2.9 KB  |  85 lines

  1. /*
  2.  * Copyright (c) 1987 University of Maryland Department of Computer Science.
  3.  * All rights reserved.  Permission to copy for any purpose is hereby granted
  4.  * so long as this copyright notice remains intact.
  5.  */
  6.  
  7. /*        C-Tex I/O definitions        */
  8.  
  9. /*
  10.  * For non-ASCII systems, someone would have to do a great deal of work
  11.  * in the various I/O routines to use the two translation tables.  I have
  12.  * not the motivation.
  13.  */
  14. #ifdef notdef
  15. int    InX[128];        /* input translation table */
  16. int    OutX[128];        /* output translation table */
  17. #endif
  18.  
  19. /*
  20.  * These `magic constants' are really the best we can do.  Using termcap
  21.  * would not be quite right, because (1) the C-TeX run may not be on a
  22.  * terminal at all, and (2) the log file could very likely be viewed from
  23.  * a different terminal than was used for the C-TeX run.
  24.  */
  25. #define MaxPrLineLen    72    /* will try to never print lines longer
  26.                    than this */
  27. #define MaxErrLineLen    72    /* errors (context actually) will never
  28.                    be longer than this */
  29. #define HalfErrLine    42    /* about 1/2 MaxErrLineLen; this will be
  30.                    the width of first lines of contexts */
  31.  
  32. /*
  33.  * Input will be read into lines of InBufLen characters.  This limits
  34.  * several things, including control sequence name length and length of
  35.  * strings read by \read.
  36.  */
  37. #define InBufLen    512
  38.  
  39. /* Output descriptors.  Note that 0-15 are indexes into OutF. */
  40. #define OutIgnore    16    /* nowhere; output is silently discarded */
  41. #define OutTerm        17    /* to terminal (stdout) */
  42. #define OutLog        18    /* to log file */
  43. #define OutTermAndLog    19    /* to terminal & log file both */
  44. #define OutString    20    /* to PoolString */
  45. #define OutCircBuf    21    /* to CircBuf */
  46.  
  47. int    OutFD;            /* the current output descriptor */
  48. FILE    *LogF;            /* the log file */
  49. FILE    *InF[16];        /* the 16 \read descriptors */
  50. FILE    *OutF[16];        /* the 16 \write descriptors */
  51. char    CircBuf[MaxErrLineLen];    /* this will be used for showing error
  52.                    context; its length determines the
  53.                    maximum amount of context that can
  54.                    be shown.  This is a way of getting
  55.                    around a possibly massive amount of
  56.                    stuff leading up to the point of the
  57.                    error, without using backpointers.
  58.                    Inefficient perhaps, but it does not
  59.                    occur often. */
  60.  
  61. /*
  62.  * On occasion it is nice to be able to interrupt the current output
  63.  * descriptor and switch to a new one.  This does not happen often,
  64.  * so we just have a small stack of them here.
  65.  */
  66. int    OutFDstack[20];
  67. int    *OutFDsp;
  68.  
  69. /* macros to switch to a new output, then restore the old */
  70. #define PushOut(fd)    (*OutFDsp++ = OutFD, OutFD = (fd))
  71. #define PopOut()    (OutFD = *--OutFDsp)
  72.  
  73. /*
  74.  * The following magic variables are used by ShowContext to control the info
  75.  * being inserted into the CircBuf.
  76.  */
  77. int    OutTally;        /* total characters recently printed */
  78. int    OutSC_max;        /* max needed by ShowContext */
  79.  
  80. /*
  81.  * UpdateTerminal makes sure that all output is visible by the user.
  82.  * In this case all we need to do is fflush(stdout).
  83.  */
  84. #define UpdateTerminal() ((void) fflush(stdout))
  85.